<html>
<head>
 <meta charset="UTF-8">
 <meta name="viewport"
       content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title>Document</title>
</head>
<body>
<div id="divOutput"></div>
</body>
<style>
 body {
  background: black;
  color: #fff;
  margin: 2rem;
  font: bold 24px Consolas, Monaco, monospace;
 }
</style>
<script>

 var str = "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"
 var i = 0;
 function outPuting(){
  var divOutput = document.getElementById('divOutput')
  if(i<=str.length){
   divOutput.innerHTML = str.slice(0,i++) + "_";
   setTimeout("outPuting()",100)
  }else{
   divOutput.innerHTML = str;
  }
 }
 outPuting();
 // 停止计时器
 function stopSetTimeout() {
  var highestTimeoutId = setTimeout(';');
  for (var i = 0; i < highestTimeoutId; i++) {
   clearTimeout(i);
  }
 }

</script>
</html>





